<?
	//ini_set('display_errors', 'On');
	//error_reporting(E_ALL);
	$DEBUGGING = false;
	$TRACECOUNT = 0;
	 
	if($DEBUGGING)
	{		
		ini_set('display_errors', 'On');
		error_reporting(E_ALL);
	}
	 
	function trace($message)
	 {
		global $DEBUGGING;
		global $TRACECOUNT;
		if($DEBUGGING)
		{
			echo '<hr />;'.$TRACECOUNT++.'<code>'.$message.'</code><hr />';
		}
	}
	 
	function tarr($arr)
	{
		global $DEBUGGING;
		global $TRACECOUNT;
		if($DEBUGGING)
		{
			echo '<hr />'.$TRACECOUNT++.'<code>';
			print_r($arr);
			echo '</code><hr />';
		}
	} 
	global $table_edit, $config_xml_list, $config_xml_edit, $db, $lg;
	
	$table_edit = "get_articles";
	
	$sql = "select * from config_view where active = 1 and type = 1 and alias = '".$table_edit."'";
	//echo $sql;
	$arr = $db->getRow($sql);
	$config_xml_list = isset($arr)?$arr['values']:'11111';
	
	$sql = "select * from config_view where active = 1 and type = 2 and alias = '".$table_edit."'";
	//echo $sql;
	$arr = $db->getRow($sql);
	$config_xml_edit = isset($arr)?$arr['values']:'11111';
	//echo $config_xml_edit;
?>
<?
	include("ckeditor_config.php");	
	include("lib/PHPSimpleHTMLDOM/simple_html_dom.php");	
switch($act){	
	
	case "transfer_full":
	transferDataToArticles($_GET['id']);
	//$tpl="list_full";
	break;
	
	case "add_full":
	case "edit_full":	
	EditFull();
	$title_page = "Chỉnh Sửa";
	$tpl="edit_full";
	break;
	
	case "del":
	Del();
	break;
		
	case "changeactive":
	ChangeActive("active");
	break;
	
	case "changehome":
	ChangeActive("home");
	break;
	
	case "transfer_list":
	TransList();
	break;
	
	case "dellist":
	DelList();
	break;
	
	case "show":
	ChangeShowList("active");
	break;
	
	case "hide":
	ChangeHideList("active");
	break;
		
	case "order":
	Order();
	break;
	
	case "list_full":
	ShowListFull();
	$title_page = "CMS - Sản phẩm";
	$tpl="list_full";
	break;	
	
	
	case "get_data_from_stack":
	GETDataFromStack();	
	$tpl="list_full";
	break;		
	
	case "do_not_get":
	ShowListFull2("3");
	$tpl="list_full";
	break;
	
	case "list":
	ShowListFull2("1");
	$tpl="list_full";
	break;
	
	case "done":
	ShowListFull2("2");
	$tpl="list_full";
	break;
	
	case "get_link_to_stack":	
	mainGetDataDiaOc();	
	mainGetDataCafef();	
	$tpl="list_full";
	break;
	
	default:
	ShowListFull2("1 or status = 3 ");
	$title_page = "CMS - Sản phẩm";
	$tpl="list_full";
}
function removeNode($html, $selector)
{
    foreach ($html->find($selector) as $node)
    {
        $node->outertext = '';
    }

    $this->load($this->save());        
}
function removeDiaOcMain($html)
{
	return removeDiaOc($html, "p[align=right]", "div i b");
}
function removeCafeLandError($html)
{	
	$str = '';
	$str2 = '';
	$selector = 'img';
	$html = str_get_html($html);
	//echo 'test 123';
	foreach ( $html->find("img", 0)->attr as &$value ){
		echo $value;
		$value = null;
	}

	return $html;
}
function removeDiaOc($html, $selector, $selector2)
{	
	$str = '';
	$str2 = '';
	
	$html = str_get_html($html);
	
	foreach ($html->find($selector) as $node)
    {
		$str = $node->innertext;
    }
	
	
	foreach ($html->find($selector2) as $node)
    {
		$str2 = $node->innertext;
    }	   

	$rs = str_replace($str, '',$html->innertext);
	return str_replace($str2, '',$rs);
}
function removeCafefMain($html)
{
	return removeCafef($html, "p[class=author]", "p[class=author]");
}
function removeCafef($html, $selector, $selector2)
{	
	$str = '';
	$str2 = '';
	
	$html = str_get_html($html);
	
	foreach ($html->find($selector) as $node)
    {
		$str = $node->innertext;
    }
	$rs = str_replace($str, '',$html->innertext);
		
	foreach ($html->find($selector2) as $node)
    {
		$str2 = $node->innertext;
    }	   
	
	return str_replace($str2, '',$rs);
}
function mainGetDataCafef()
{
	global $table_edit, $stack;
	$TheDivBig = 'div[class="ca-hot"] div[class="cah-top clearfix"]';
	$TheDivList = 'div[class=cc-tinkhac] div[class=cc-list] div[class=item]';

	$link_new = 'http://land.cafef.vn/thi-truong.chn';	
	$stack = '3';
	getHTMLNewListLandCafefStack($link_new, $TheDivBig, $TheDivList, '758');	
	
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');

	page_transfer2($page);
}
function mainGetDataDiaOc()
{
	global $table_edit, $stack;
	$TheDivBig = 'div[class="NewsTopDetail"]';
	$TheDivList = 'div[class="ListTin"] ul li';
	$stack = '2';

	$link_new = 'http://www.diaoconline.vn/tin-tuc/tin-dia-oc/1/';	
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '758');	
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/kham-pha--trai-nghiem/3/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '749');	
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/hoat-dong-doanh-nghiep/23/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '763');	
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/chinh-sach--quy-hoach/16/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '760');
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/phan-tich--nhan-dinh/58/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '759');
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/tai-chinh--chung-khoan/57/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '762');	
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/khong-gian-song/7/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '749');	
	
	$link_new = 'http://www.diaoconline.vn/tin-tuc/phong-thuy/9/';
	getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, '756');	
	
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');

	//page_transfer2($page);
}
function ShowListFull2($status)
{
	global $db, $table_edit, $arr, $elements, $db_name;
	
	$sql = "select column_name from information_schema.columns where table_name='".$table_edit."' AND table_schema ='".$db_name."'" ;
	
	$arr = $db->getAll($sql);
	
	$elements = ShowListArr2($table_edit, $status);
}
function ShowListArr2($table_edit, $status)
{
	global $db, $page, $plpage, $set_per_page, $c;
	$set_per_page=20; 
	if(isset($_GET['cid']) && $_GET['cid']!=1 && $_GET['cid']!='')
		$sql="select p.* from ".$table_edit." p where p.cid=".$_GET['cid']." and status = ".$status." order by p.num asc, p.id desc ";
	else
		$sql="select * from ".$table_edit." where status = ".$status." order by num asc, id desc ";
	//echo $sql;	
	$c = $db->numRows($db->query($sql));
	$plpage = plpage($sql,$page,$set_per_page);
	$sqlstmt = sqlmod($sql,$page,$set_per_page);	
	return $db->getAll($sqlstmt);	
}
function GETDataFromStack()
{
	global $db, $FullUrl, $lg;
	$table_select = 'get_articles';
	$sql = "select * from ". $table_select . " where status = 3 limit 5";
	
	$arr = $db->getAll($sql);
	
	//print_r($arr); 
	if(count($arr)>0)
	{	
		for($i = 0; $i < count($arr); $i++)	
		{
			GETDataFromLink($arr[$i]);	
		}
	}
	
	$page="admin-pro.html?do=".$table_select. (isset($_GET['page'])?'&page='.$_GET['page']:'');

	page_transfer2($page);	
	
}
function GETDataFromLink($arrLinkE)
{
	global $arrIMGMain, $arrIMG, $db, $FullUrl, $lg;
	$table_update = "get_articles";
	$index = 0;
	
	if($arrLinkE['link_href'] != '')
	{
		$html = file_get_html($arrLinkE['link_href']);		
		
		$detail = '';
		if($arrLinkE['stack'] == '2')
		{
			//Detail
			$detail = $html->find('div[class="contentDetail"] div[class="TinDetail"] div[class="chitiet"]', 0);
			
			//DateA
			$arrLinkE['date_post'] = $html->find('div[class=TinDetail] div[class=dateA]',0)->innertext;	
		}
		else if($arrLinkE['stack'] == '3')
		{
			
			//Detail
			$detail = $html->find('div[class=category] div[class=postdetail] div[class=KenhF_Content_News3]', 0);
			//print_r($detail->innertext);
			//DateA
			$arrLinkE['date_post'] = $html->find('div[class=cattitle] span[class=newsdate]',0)->innertext;		
			
			
			//http://cafef3.vcmedia.vn/images/btn_a+.gif
			//http://cafef3.vcmedia.vn/images/btn_a.gif
			//http://cafef3.vcmedia.vn/images/btn_a-.gif
		}
		if($detail != '')
		{
			$arrLinkE['content_vn'] = $detail->innertext;
			//print_r($arrLinkE['content_vn']);
			//echo 'stack:'.$arrLinkE['stack'];
			//List Images
			foreach($detail->find('img') as $elementIMG)
			{
				$arrIMG[$index] = $elementIMG->src;
				
				//echo $arrIMG[$index];
				$index++;
			}		
			
			if($index > 0)
				$arrLinkE['content_vn'] = downloadImageFromContent2($detail->innertext);
			
			// DiaOc
			if($arrLinkE['stack'] == '2')	
				$arrLinkE['content_vn'] = removeDiaOcMain($arrLinkE['content_vn']);	
			if($arrLinkE['stack'] == '3')
				$arrLinkE['content_vn'] =  removeCafefMain($arrLinkE['content_vn']);	
				
			$arrLinkE['id_user'] = '2009';
			$arrLinkE['status'] = '1';
			
			if($arrLinkE['stack'] == '3')	
			{
				$temp = $html->find('div[class=postdetail] div[id=ctl00_contentMain_ucNewsDetail1_divImage] img', 0)->src;
				if($temp != '')
				{
					$temp2 = downloadImageFromLink($temp);
					$arrIMGMain = $temp2['link_get'];
					echo $arrIMGMain; 	
				}
			}
			$arrLinkE['img'] = $arrIMGMain;
			$arrIMGMain = '';	
			
			//Get Unique Key
			if($arrLinkE['name_vn'])
			{
				$unique_key_vn = CreateUniqueKey($arrLinkE['name_vn']);		
				$arrLinkE['unique_key_vn'] = $unique_key_vn;
				
				$arrLinkE['title_vn'] = $arrLinkE['keyword_vn'] = $arrLinkE['des_vn'] = $arrLinkE['seo_f_vn'] = strtolower($arrLinkE['name_vn']).", ". CreateTitleKey($arrLinkE['name_vn']);
			}
					
			$postId = vaUpdate2($table_update,$arrLinkE, " id=".$arrLinkE['id']);
			$msg="Insert GET Data From Stack";	
		}
		
	}
	
}
function getDataImgLand()
{
	
}
// Get Link Input Stack
function getHTMLNewListLandCafefStack($link_new, $TheDivBig, $TheDivList, $cid)
{
	//$link_new = 'http://land.cafef.vn/thi-truong.chn';	
	//$TheDivBig = 'div[class="NewsTopDetail"]';
	//$TheDivList = 'div[class="ListTin"] ul li';
	//$cid = 758;
	$index = 1;
	$arrLink[0]['cid'] = $cid;
	
	// Create DOM from URL or file
	$html = file_get_html($link_new);	
	
	//Find Article New Big
	$html_big = $html->find($TheDivBig, 0);
	$arrLink[0]['link'] = "http://land.cafef.vn".$html_big->find('a', 0)->href;
	$arrLink[0]['title'] = $html_big->find('h3 a', 0)->plaintext;	
	$arrLink[0]['short'] = $html_big->find('div[class="cah-info"] p', 0)->plaintext;		
		
	// Find Article New List	
	foreach($html->find($TheDivList) as $element)
	{
		$arrLink[$index]['link'] = "http://land.cafef.vn".$element->find('a', 0)->href;
		$arrLink[$index]['cid'] = $cid;
		$arrLink[$index]['title'] = htmlspecialchars($element->find('div[class="cclinfo"] h4 a', 0)->plaintext);
		$arrLink[$index]['short'] = htmlspecialchars($element->find('div[class="cclinfo"] p', 0)->plaintext);
		$arrLink[$index]['update'] = $element->find('div[class="date"]', 0)->plaintext;
		
		$index ++;
	}		
	
	//print_r($arrLink);
	SaveLinkInputData($arrLink);
}
// Get Link Input Stack
function getHTMLNewListLandDiaOcOnlineStack($link_new, $TheDivBig, $TheDivList, $cid)
{
	//$link_new = 'http://www.diaoconline.vn/tin-tuc/tin-dia-oc/1/';	
	//$TheDivBig = 'div[class="NewsTopDetail"]';
	//$TheDivList = 'div[class="ListTin"] ul li';
	//$cid = 758;
	$index = 1;
	$arrLink[0]['cid'] = $cid;
	
	// Create DOM from URL or file
	$html = file_get_html($link_new);	
	
	//Find Article New Big
	$html_big = $html->find($TheDivBig, 0);
	$arrLink[0]['link'] = $html_big->find('a', 0)->href;
	$arrLink[0]['title'] = $html_big->find('h3 a', 0)->plaintext;	
	$arrLink[0]['short'] = $html_big->find('p', 1)->plaintext;		
		
	// Find Article New List	
	foreach($html->find($TheDivList) as $element)
	{
		$arrLink[$index]['link'] = $element->find('a', 0)->href;
		$arrLink[$index]['cid'] = $cid;
		$arrLink[$index]['title'] = htmlspecialchars($element->find('div[class="ListTinTitle"] a', 0)->plaintext);
		$arrLink[$index]['short'] = htmlspecialchars($element->find('div[class="ListTinText"]', 0)->plaintext);
		$arrLink[$index]['update'] = $element->find('div[class="ListTinUpdate"]', 0)->plaintext;
		
		$index ++;
	}		
	
	//print_r($arrLink);
	SaveLinkInputData($arrLink);
}
function SaveLinkInputData($arrLink)
{
	global $db, $FullUrl, $lg, $stack;
	$tableInsert = 'get_articles';
	$len = count($arrLink);
	
	for($i = 0; $i < $len; $i++)
	{
		$unique_key = CreateUniqueKey($arrLink[$i]['title']);	
		//echo $unique_key;
		if(CheckUniqueKeyGET($unique_key) == 0)
		{
			$arr['cid'] = $arrLink[$i]['cid'];
			$arr['link_href'] = $arrLink[$i]['link'];
			$arr['name_vn'] = $arrLink[$i]['title'];
			$arr['short_vn'] = $arrLink[$i]['short'];
			$arr['unique_key_vn'] = $unique_key;			
			$arr['status'] = '3';
			$arr['stack'] = $stack;
			
			vaInsert($tableInsert, $arr);
		}
		else
		{
			if(CheckLinkGET($arrLink[$i]['link']) == 0)
			{
				$arr['cid'] = $arrLink[$i]['cid'];
				$arr['link_href'] = $arrLink[$i]['link'];
				$arr['name_vn'] = $arrLink[$i]['title'];
				$arr['short_vn'] = $arrLink[$i]['short'];
				$arr['unique_key_vn'] = $unique_key.'-2';			
				$arr['status'] = '3';
				$arr['stack'] = $stack;
				
				vaInsert($tableInsert, $arr);
			}
		}
		
	}
	
	$msg="Get Link Form Web Complete.";	
	
	//$page="admin-pro.html?do=".$tableInsert. (isset($_GET['page'])?'&page='.$_GET['page']:'');

	//page_transfer2($page);	
}

function transferDataToArticles($id_getData)
{
	global $db, $FullUrl, $table_edit;
	$table_insert = 'articles';
	$sql = "select * from ".$table_edit." where id=". $id_getData;	
	//echo $sql;
	$element = $db->getRow($sql);
	
	$arr['cid'] = $element['cid'];
	$arr['name_vn'] = $element['name_vn'];
	$arr['content_vn'] = $element['content_vn'];
	$arr['short_vn'] = $element['short_vn'];
	$arr['img'] = $element['img'];
	$arr['active'] = '1';
	
	if($arr['name_vn'])
	{
		$unique_key_vn = CreateUniqueKey($arr['name_vn']);		
		$arr['unique_key_vn'] = $unique_key_vn;
		
		$arr['title_vn'] = $arr['keyword_vn'] = $arr['des_vn'] = $arr['seo_f_vn'] = strtolower($arr['name_vn']).", ". CreateTitleKey($arr['name_vn']);
		
		//print($arr['unique_key_vn']);
	}
	$test = CheckUniqueKey2($arr['unique_key_vn']);
	
	//Check Unique Key
	if($test == '1')
	{		
		$nowtime = time();			
		$arr['unique_key_vn'] = $arr['unique_key_vn'] . "-".$nowtime;	
		
	}	
	$postId = vaInsert($table_insert,$arr);
	$msg="Add successfully";	
	//print_r($arr);
	updateStatusGETDATA($id_getData);
	
	//$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');
	//print_r($arr);
	//page_transfer2($page);	
}
function updateStatusGETDATA($id_getData)
{
	global $db, $FullUrl, $table_edit;
	
	$arr['status'] = '2';
	
	vaUpdate($table_edit, $arr, "id = ".$id_getData);
	
		
}
function getDataDiaOcOnline()
{
	global $arrNew, $arrIMG, $db, $FullUrl, $table_edit, $arrIMGMain;
	$arr['content_vn'] = $arrNew['detail'];
	$arr['content_vn'] = downloadImageFromContent($arr['content_vn']);
	$arr['name_vn'] = $arrNew['title'];
	$arr['short_vn'] = $arrNew['short'];
	$arr['link_href'] = $arrNew['link'];
	$arr['cid'] = isset($arrNew['cid'])?$arrNew['cid']:'0';
	$arr['id_user'] = '2009';
	$arr['date_post'] = $arrNew['date_post'];
	if($arrIMGMain != '')
	{
		$arr['img'] = $arrIMGMain;
		$arrIMGMain = '';		
	}
		//print_r($arr['content_vn']);
	//Get Unique Key
	if($arr['name_vn'])
	{
		$unique_key_vn = CreateUniqueKey($arr['name_vn']);		
		$arr['unique_key_vn'] = $unique_key_vn;
		
		$arr['title_vn'] = $arr['keyword_vn'] = $arr['des_vn'] = $arr['seo_f_vn'] = strtolower($arr['name_vn']).", ". CreateTitleKey($arr['name_vn']);
		
		//print($arr['unique_key_vn']);
	}
	$test = CheckUniqueKey3($arr['unique_key_vn'], $arr['img']);
		
	//Check Unique Key
	if($test == '1')
	{		
		$nowtime = time();			
		$arr['unique_key_vn'] = $arr['unique_key_vn'] . "-".$nowtime;	
		
	}	
	
	if($test != '2')
	{	
		$postId = vaInsert($table_edit,$arr);
		$msg="Add successfully";	
	}
	//$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');
	//print_r($arr);
	//page_transfer2($page);	
}



function EditSMFull()
{
	global $db,$act, $FullUrl, $table_edit, $arrImageHost, $lg;	
	
	$sql = "select column_name from information_schema.columns where table_name='".$table_edit."'";
	
	$arr_table = $db->getAll($sql);
	
	$arr = NULL;
	
	for($i = 0; $i < count($arr_table);$i++)
	{
		$name_label = $arr_table[$i]['column_name'];
		//$type_label = $arr_table[$i]['data_type'];
		
		if($name_label == 'cid')
		{
			$arr = ArrPostClean2($arr, 'cid', 'cat');
		}
		else if($name_label == 'active' || $name_label == 'home')
		{
			$arr = ArrPostCleanActive($arr, $name_label);
		}
		else if($name_label == 'img')
		{
			if(isset($_FILES['img']['name'] ) && $_FILES['img']['size']>0){
				$img = $_FILES['img']['name'];
				$start = strpos($img,".");
				$type = substr($img,$start,strlen($img));
				CheckUpload($type);
				
				$filename = strtolower(substr($img, 0,$start));
				$filename = RenameFile($filename).$type;
				if(file_exists( "./kam/upload/images/articles/" . $filename)){
					$filename = substr($img, 0, $start);
					$filename = $_POST["unique_key_vn"] . '-' . time() . $type;
					
				}
				else
				{
					// Khong co
				}
				copy($_FILES['img']['tmp_name'], "./kam/upload/images/articles/" . $filename) ;
				$arr['img'] = "kam/upload/images/articles/" . $filename;
			}
			else
			{				
				if(isset($_COOKIE['images_drag_flag']))
				{	
					if ($_COOKIE['images_drag_flag'] == 'true' && $_COOKIE['images_drag'] != '' && $_SESSION['images_drag'] != $_COOKIE['images_drag'])
					{
						$arr['img'] = 'kam/upload/images/drag/'.$_COOKIE['images_drag'];
						
						
						//setcookie ("images_drag", "", time()-864000); 
						//setcookie ("images_drag_flag", "", time()-864000); 
						$_SESSION['images_drag'] = $_COOKIE['images_drag'];
						$_SESSION['images_drag_flag'] = false;
						RemoveCookieLive('images_drag');
						RemoveCookieLive('images_drag_flag');
					
					}
				}
				else
				{		
				}
			}
		}
		else
		{
			$arr = ArrPostClean($arr, $name_label);
		}

	}
	//print_r($arr['content_vn']);
	$arr['content_vn'] = DownloadImage($arr['content_vn']);
		//print_r($arr['content_vn']);
	//Get Unique Key
	if($arr['name_vn'])
	{
		$unique_key_vn = CreateUniqueKey($arr['name_vn']);		
		$arr['unique_key_vn'] = $unique_key_vn;
		
		$arr['title_vn'] = $arr['keyword_vn'] = $arr['des_vn'] = $arr['seo_f_vn'] = strtolower($arr['name_vn']).", ". CreateTitleKey($arr['name_vn']);
		
		//print($arr['unique_key_vn']);
	}
	$test = CheckUniqueKey2($arr['unique_key_vn']);
		
	//Check Unique Key
	if($test == '1')
	{		
		$nowtime = time();			
		$arr['unique_key_vn'] = $arr['unique_key_vn'] . "-".$nowtime;	
		
	}	
	// Kết thúc phần mở rộng
	
	if ($act=="addsm_full")
	{
		
				
		if(!file_exists($arr['img']) || $arr['img'] == '' || !isset($arr['img']))
		{
			if(count($arrImageHost))
			{
				if($arrImageHost[0][0] == '/')
				{
					$str_temp = "";
					for($i = 1; $i < strlen($arrImageHost[0]); $i++)
					{
						$str_temp .= $arrImageHost[0][$i];	
					}	
					$arr['img'] = $str_temp;
				}
				else
					$arr['img'] = $arrImageHost[0];
				
			}
		}
		// Xử lý Image
		$postId = vaInsert($table_edit,$arr);
		$msg="Add successfully";	
	}
	else
	{
		// Xử lý Image
		$id=$_POST['id'];
		if (isset($arr['img'])){
			$sqlstmt="select img from ".$table_edit." where id=$id";
			$r = $db->getRow($sqlstmt);
			if(file_exists($r['img'])) unlink($r['img']);
		}
		vaUpdate($table_edit, $arr,' id='.$id);	
		$msg="Đã Edit successfully";	
	}
	
	$msg="Add successfully";
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');
	//print_r($arr);
	page_transfer2($page);		
}
?>
<?
/*
function getHTMLNewListLandDiaOcOnline($link_new, $div_class, $cid)
{
	global $arrNew, $arrIMG;
	$arrNew = null;
	$arrIMG = null;
	$index = 0;
	$arrNew['cid'] = $cid;
	
	// Create DOM from URL or file
	$html = file_get_html($link_new);
	
	
	// Find Article New
	$theDIV = 'div[class="ListTin"] ul li';
	//echo $theDIV;
	foreach($html->find($theDIV) as $element)
	{
		$eA = $element->find('a');
		// Link
		//echo 'Link'. '<br>';
		$link = $eA[0]->href;
		$arrNew['link'] = $link;
		echo $link . '<br/>';
		
		// Find Image & Detail
		$html2 = file_get_html($link);
		
		//Detail
		$element2 = $html2->find('div[class="contentDetail"] div[class="TinDetail"] div[class="chitiet"]', 0);
		$detail = $element2;
		$arrNew['detail'] = $detail->innertext;
		
		//List Images
		foreach($detail->find('img') as $element3)
		{
			$img = $element3->src;
			$arrIMG[$index] = $img;
			$index++;
			//echo $img . '<br>';
				
		}		
		
		//Date
		$element4= $html2->find('div[class="contentDetail"] div[class="TinDetail"] div[class="dateA"]', 0);
		$arrNew['date_post'] = $element4->innertext;
		
		//Short
		$element5 = $element->find('div[class="ListTinText"]', 0);
		$arrNew['short'] = $element5->plaintext;		
		
		//Title
		$element6 = $element->find('div[class="ListTinTitle"] a', 0);
		$arrNew['title'] = $element6->plaintext;
		
		getDataDiaOcOnline();
		
	}		
}
//'http://www.diaoconline.vn/tin-tuc/tin-dia-oc/1/'
function getHTMLNewLandDiaOcOnline($link_new, $div_class, $cid)
{
	global $arrNew, $arrIMG;
	$arrNew = null;
	$arrIMG = null;
	$index = 0;
	$arrNew['cid'] = $cid;
	
	// Create DOM from URL or file
	$html = file_get_html($link_new);
	
	
	// Find Article New
	//$theDIV = 'div[class="'.$div_class.'"]';
	//echo $theDIV;
	foreach($html->find($theDIV) as $element)
	{
		$eA = $element->find('a');
		// Link
		//echo 'Link'. '<br>';
		$link = $eA[0]->href;
		$arrNew['link'] = $link;
		//echo $link . '<br>';
		
		// Find Image & Detail
		$html2 = file_get_html($link);
		
		foreach($html2->find('div[class="contentDetail"] div[class="TinDetail"] div[class="chitiet"]') as $element2)
		{
			// Detail
			//echo 'Detail'. '<br>';
			$detail = $element2;
			$arrNew['detail'] = $detail->innertext;
			//echo $detail . '<br>';
			
			foreach($detail->find('img') as $element3)
			{
				$img = $element3->src;
				$arrIMG[$index] = $img;
				$index++;
				//echo $img . '<br>';
					
			}
		}
		foreach($html2->find('div[class="contentDetail"] div[class="TinDetail"] div[class="dateA"]') as $element4)
		{
			$arrNew['date'] = $element4->innertext;
		}
			
		foreach($element->find('p') as $eP)
		{
			// Short
			//echo 'Mô tả ngắn'. '<br>';
			$short = $eP->plaintext;
			$arrNew['short'] = $short;
			//echo $short . '<br>';
		}
			
		foreach($element->find('H3') as $eH3)
		{
			// Title
			//echo 'Title'. '<br>';
			$title = $eH3->plaintext;
			$arrNew['title'] = $title;
			//echo $title . '<br>';	
		}	
		//echo '<br>';
	}	
	getDataDiaOcOnline();
	//print_r($arrNew);
	//print_r($arrIMG);
}

*/
?>